import axios from './http'

var  depot = {}

depot.get =  function ({ url, config = {}, cb }) {
     axios.get(url, config).then((res) => {
        if (res.status === 200) {
            let result = res.data;
            cb(result);
        }
    }).catch((error) => {
        console.log('请求错误：' + error);
    });
};

depot.post =  function ({ url, data, cb }) {
     axios.post(url, data).then(
        (res) => {
            if (res.status === 200) {
                if (res.status === 200) {
                    let result = res.data;
                    cb(result);
                }
            }
        }).catch((error) => {
        console.log(error);
    });
};


depot.delete = function({url, params}) {
    return new Promise((resolve, reject) => {
        axios.delete(url, params)
            .then(res => {
                resolve(res.data);
                // // Loading.service(true).close();
                //  Message({message: '请求成功', type: 'success'});
                if (res.status === 200) {
                    if (res.status === 200) {
                        let result = res.data;
                        cb(result);
                    }
                }
            })
            .catch(err => {
                reject(err.data)
                // Loading.service(true).close();
                // Message({message: '加载失败', type: 'error'});
                console.log(err);
            })
    });
}


export default () => {
    window.depot = depot;
};

